package leetcode;

public class _0154 {
    /**
     * 寻找旋转排序数组中的最小值 II
     */
    class Solution {
        public int findMin(int[] nums) {
            int n = nums.length;
            int left = 0;
            int right = n-2;
            while(left<=right){
                int mid = left+(right-left)/2;
                if(nums[mid]<nums[right+1]){
                    right = mid-1;
                }else if(nums[mid]>nums[right+1]){
                    left = mid+1;
                }else{
                    right--;
                }
            }
            return nums[left];
        }
    }
}
